package com.szqhyxj.youxiangju.biz.equipmentActivation.activationrecord;

import android.util.Log;

import com.szqhyxj.youxiangju.sys.BaseResult;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by leung on 2018/11/11.
 */

public class ActivationRecordPresenter implements ActivationRecordContract.Presenter {
    ActivationRecordContract.View view;

    public ActivationRecordPresenter(ActivationRecordContract.View view) {
        this.view = view;
    }

    @Override
    public void onDestroy() {

    }

    @Override
    public void getRecordList(String devNo) {
        ActivationRecordModel.getportorder(devNo)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<BaseResult<List<ActivationRecordModel.RecordEntity>>>() {
                    @Override
                    public void accept(BaseResult<List<ActivationRecordModel.RecordEntity>> baseResult) throws Exception {
                        if (baseResult.businessLogicSuccess()) {
                            List<ActivationRecordModel.RecordEntity> list = new ArrayList<>();
                            list = baseResult.getData();
                            Log.e("===============",list.size()+"");
                            view.showList(list);
                        } else {

                        }
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {

                    }
                });
    }
}
